# Validate HPE Ezmeral Container Platform deployment

This section deploys a sample application to validate the deployment of HPE Ezmeral Container Platform.

# Deploying WordPress application with HPE Ezmeral Data Fabric

The following example is based on WordPress and MySQL with Persistent Volume sample scenario described in kubernetes.io.

MySQL and WordPress require a Persistent Volume to store data. Their persistent volume claim will be created at the deployment step. HPE Ezmeral Container Platform setup uses MapR as the default persistent volume.

Add a secret generator in kustomization.yaml from the following command. You will need to replace YOUR_PASSWORD with the password you want to use.

> mkdir wordpress
> cd wordpress
> cat <<EOF >./kustomization.yaml
secretGenerator:
- name: mysql-pass
literals:
- password=YOUR_PASSWORD
EOF

Download these two yaml manifest files for MySQL and WordPress services respectively:

> curl -kO https://kubernetes.io/examples/application/wordpress/mysql-deployment.yaml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1238 100 1238 0 0 1430 0 --:--:-- --:--:-- --:--:-- 1429

> curl -kO https://kubernetes.io/examples/application/wordpress/wordpress-deployment.yaml
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1323 100 1323 0 0 1441 0 --:--:-- --:--:-- --:--:-- 1441

> ls -al
total 9
drwxr-xr-x 1 leedavid UsersGrp 0 Nov 28 16:50 .
drwx------ 1 leedavid UsersGrp 0 Nov 28 16:46 ..
-rw-r--r-- 1 leedavid UsersGrp 137 Nov 28 16:49 kustomization.yaml
-rw-r--r-- 1 leedavid UsersGrp 1238 Nov 28 16:47 mysql-deployment.yaml
-rw-r--r-- 1 leedavid UsersGrp 1323 Nov 28 16:50 wordpress-deployment.yaml

# Persistent Storage configuration

If you have installed HPE Ezmeral Container Platform with tenant storage, then HPE Ezmeral Container Platform will already have registered MapR as the default Storage Class in this namespace.

> kubectl get StorageClass
NAME PROVISIONER AGE
default (default) com.mapr.csi-kdf 39h

> kubectl describe StorageClass
Name: default
IsDefaultClass: Yes
Annotations: storageclass.kubernetes.io/is-default-class=true
Provisioner: com.mapr.csi-kdf
Parameters: cldbHosts=16.143.20.131:7222,cluster=epic.mapr.cluster,csi.storage.k8s.io/provisioner-secret-name=mapr-user-secret,csi.s torage.k8s.io/provisioner-secret-namespace=mapr-csi,csiNodePublishSecretName=mapr-ticket-secret,csiNodePublishSecretNamespace=mapr-csi,mountPre fix=/mapr-csi,namePrefix=k8s-1-,platinum=true,restServers=16.143.20.131:8443,securityType=secure
AllowVolumeExpansion: <unset>
MountOptions: <none>
ReclaimPolicy: Delete
VolumeBindingMode: Immediate
Events: <none>

In these 2 manifest files, both WordPress service and MySQL are requesting for persistent volume (PV):

# MySQL deployment

# WordPress Deployment

In both pods, there is no explicit request for specific storageClassName. Hence, it will use the default StorageClass, that is MapR storage.

# NodePort Service

Edit wordpress manifest yaml to use NodePort service instead of load balancer service.

This is needed so that HPE Ezmeral Container Platform will do port remap.

> vi wordpress-deployment.yaml
> cat wordpress-deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: NodePort
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: wordpress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-pass
key: password
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim

# Deploy the services

Add these two deployment manifests to kustomization.yaml file.

> cat <<EOF >>./kustomization.yaml
resources:
- mysql-deployment.yaml
- wordpress-deployment.yaml
EOF

The kustomization.yaml contains all the resources for deploying a WordPress site and a MySQL database. You can apply the directory and verify MapR volume and all the services:

> kubectl apply --kustomize ./
secret/mysql-pass-9tt65k5fgm created
service/wordpress-mysql created
service/wordpress created
deployment.apps/wordpress-mysql created
deployment.apps/wordpress created
persistentvolumeclaim/mysql-pv-claim created
persistentvolumeclaim/wp-pv-claim created

Confirm PVC is using MapR StorageClass.

> kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
mysql-pv-claim Bound mapr-pv-16f97a33-b8dd-488a-b6db-1d94a84286e2 20Gi RWO default 48s
wp-pv-claim Bound mapr-pv-896b3504-e9ba-4593-b9a0-88a9ece392b5 20Gi RWO default 48s

> kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
mapr-pv-32850109-ef66-42db-9522-b563fbc01eae 10Gi RWO Delete Bound bdwebterm/p-kdss-977sb-0 default 41h
mapr-pv-a24b1733-39db-40d2-bdaf-0be7c22ed83b 10Gi RWO Delete Bound bdwebterm/p-kdss-nbwhn-0 default 31h
mapr-pv-dbf96aed-dafd-47b7-87d4-7d343f182d8b 20Gi RWO Delete Bound default/mysql-pv-claim default 69s
mapr-pv-e3c1db71-2865-425c-971e-c01466e9d295 20Gi RWO Delete Bound default/wp-pv-claim default 69s
mapr-pv-ed5f1be3-9be2-4470-83cf-67f9b31e9dbf 10Gi RWO Delete Bound bdwebterm/p-kdss-dl26j-0 default 32h

Label the WordPress service so that it will be exposed via HPE Container Platform Gateway. Note that this step is NOT necessary if the service was created in the namespace of a tenant that has "Map Services To Gateway" enabled.

> kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 26h
wordpress NodePort 10.96.98.248 <none> 80:30996/TCP 24s
wordpress-mysql ClusterIP None <none> 3306/TCP 24s

> kubectl label svc wordpress hpecp.hpe.com/hpecp-internal-gateway=true
service/wordpress labeled

> kubectl describe service wordpress
Name: wordpress
Namespace: default
Labels: app=wordpress
hpecp.hpe.com/hpecp-internal-gateway=true
Annotations: hpecp-internal-gateway/80: mip-bd-vm38.mip.storage.hpecorp.net:10006
Selector: app=wordpress,tier=frontend
Type: NodePort
IP: 10.96.98.248
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 30996/TCP
Endpoints: 10.244.2.11:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Service 26s kubedirector Created HPECP K8S service

Copy the IP address and Port number to your browser. You should see set up page similar to the following screenshot. Figure 33 depicts the WordPress welcome page.

WordPress welcome page 

Figure 36. WordPress welcome page

Destroy the application deployments (Example: pods) and restart the deployments. Validate the WordPress application information.

> kubectl delete deployment wordpress
deployment.extensions "wordpress" deleted

> kubectl delete deployment wordpress-mysql
deployment.extensions "wordpress-mysql" deleted

> kubectl get pods
No resources found.

> kubectl get deployments
No resources found.

Reapply the same deployment and reconnect to persistent storage.

> kubectl apply -k ./
secret/mysql-pass-9tt65k5fgm unchanged
service/wordpress-mysql unchanged
service/wordpress unchanged
deployment.apps/wordpress-mysql created
deployment.apps/wordpress created
persistentvolumeclaim/mysql-pv-claim unchanged
persistentvolumeclaim/wp-pv-claim unchanged

> kubectl get pods
NAME READY STATUS RESTARTS AGE
wordpress-594759d7f6-jdnvp 1/1 Running 0 27s
wordpress-mysql-847b7b996d-dwf6s 1/1 Running 0 28s

> kubectl describe service wordpress
Name: wordpress
Namespace: default
Labels: app=wordpress
Hpecp.hpe.com/hpecp-internal-gateway=true
Annotations: hpecp-internal-gateway/80: mip-bd-vm38.mip.storage.hpecorp.net:10006
Selector: app=wordpress,tier=frontend
Type: NodePort
IP: 10.96.35.129
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 31589/TCP
Endpoints: 10.244.1.18:80
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Service 12m kubedirector Created HPECP K8S service

WordPress service is restored.

Figure 34 depicts the restoration of WordPress service.

WordPress restoration service

Figure 37. WordPress restoration service

# Cleanup

To free up all the resources (including persistent storage), you will need to delete the whole deployment.

> kubectl delete -k ./
secret "mysql-pass-9tt65k5fgm" deleted
service "wordpress-mysql" deleted
service "wordpress" deleted
deployment.apps "wordpress-mysql" deleted
deployment.apps "wordpress" deleted
persistentvolumeclaim "mysql-pv-claim" deleted
persistentvolumeclaim "wp-pv-claim" deleted